/**
 * 玩家货币组件
 */
var MoneyUnit = Unit.extend({
    _ccsFileName: res.MoneyUnit_json,
    initUnit:function(){
        safeHide(this._nodeList['Click_masonry']);
        safeHide(this._nodeList['Click_gold']);
        safeHide(this._nodeList['Click_blessing']);
    },
    /**
     * 初始化货币
     * @protected
     */
    refreshData: function () {
        this._nodeList['Click_roomcard.txtCount'].setString(gameData.numOfCards[1]);
    },
    _initClickListeners: function () {
        this._super();
        this._clickListeners = {
            'Click_roomcard': '_clickCard'
        };
    },
    _initNetworkListeners: function () {
        this._networkListeners = {
            ReqFangKa: '_onReqFangKa'
        };
    },
    /**
     * 请求房卡
     * @param data
     * @private
     */
    _onReqFangKa: function (data) {
        gameData.numOfCards = data['numof_cards'];
        if (gameData.numOfCards[1]) {
            gameData.cardnum = gameData.numOfCards[1];
            this._nodeList['Click_roomcard.txtCount'].setString(gameData.cardnum || "0");
        }
        if (gameData.numOfCards[0] >= 0) {
            gameData.coinnum = gameData.numOfCards[0];
        }
        if (gameData.numOfCards[2] >= 0) {
            gameData.diamondnum = gameData.numOfCards[2];
        }
        eventManager.dispatchEvent(EventKey.UpdateFk, data);
        this.setData();
    },

    /**
     * 点击房卡
     * @private
     */
    _clickCard: function () {
        //showWindow('CoinShopWindow',CoinShopType.FangKa);
    },
    /**
     * 请求微信商店
     * @private
     */
    _requestWXShop: function () {
        showLoading("努力加载中..");
        var sendData = {area: app.parent_area, playerid: gameData.uid, unionid: gameData.unionid};
        http.post(this.WX_SHOP_URL, sendData, this._requestWXShopSuccess.bind(this), this._requestWXShopFailure.bind(this));
    },
    /**
     * 请求微信商店成功
     * @private
     */
    _requestWXShopSuccess: function (data) {
        hideLoading();
        if (!data) {
            showAlert('请求数据异常！');
            return;
        }
        this.addChild(new WxShopLayer(data));
    },
    /**
     * 请求微信商店失败
     * @private
     */
    _requestWXShopFailure: function () {
        hideLoading();
        showAlert('商店请求失败，请检查网络');
    }
});